package com.tjetc.vo;

import co.elastic.clients.elasticsearch.core.bulk.OperationType;
import com.tjetc.constant.MessageConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.UUID;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class OperationMessage implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    private String operationId;      // 唯一操作ID
    private String type;      // 操作类型
    private Object data;               // 业务数据（泛型）

    public static OperationMessage add(Object data){
        OperationMessage operationMessage = new OperationMessage();
        operationMessage.setOperationId(UUID.randomUUID().toString());
        operationMessage.setType(MessageConstant.ADD);
        operationMessage.setData(data);
        return operationMessage;
    }
    public static OperationMessage update(Object data){
        OperationMessage operationMessage = new OperationMessage();
        operationMessage.setOperationId(UUID.randomUUID().toString());
        operationMessage.setType(MessageConstant.UPDATE);
        operationMessage.setData(data);
        return operationMessage;
    }
    public static OperationMessage delete(Object data){
        OperationMessage operationMessage = new OperationMessage();
        operationMessage.setOperationId(UUID.randomUUID().toString());
        operationMessage.setType(MessageConstant.DELETE);
        operationMessage.setData(data);
        return operationMessage;
    }
    public static OperationMessage importAll(){
        OperationMessage operationMessage = new OperationMessage();
        operationMessage.setOperationId(UUID.randomUUID().toString());
        operationMessage.setType(MessageConstant.IMPORT_ALL);
        return operationMessage;
    }

    public static OperationMessage deleteAll() {
        OperationMessage operationMessage = new OperationMessage();
        operationMessage.setOperationId(UUID.randomUUID().toString());
        operationMessage.setType(MessageConstant.DELETE_ALL);
        return operationMessage;
    }
}